using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using WindowsLive.Writer.Api;

namespace WebcamSnapshotPlugin
{
	/// <summary>
	/// Summary description for SmartHelloWorldContentEditor.
	/// </summary>
	public class SmartWebcamSnapshotContentEditor : SmartContentEditor
	{
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private ISmartContentEditorSite _contentEditorSite;
        private WebcamSnapshotSettings _settings;
        private LinkLabel linkLabel1;
        private WebcamSnapshotSettings _defaultSettings;
        public SmartWebcamSnapshotContentEditor(ISmartContentEditorSite contentEditorSite, WebcamSnapshotSettings defaultSettings)
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			_contentEditorSite = contentEditorSite;
			_defaultSettings = defaultSettings;
		}

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            linkLabel1.LinkClicked += new LinkLabelLinkClickedEventHandler(linkLabel1_LinkClicked);
            linkLabel1.Links[0].LinkData = "mailto:webcamsnapshot@krapoth.info";
        }

        void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
        }

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.linkLabel1 = new System.Windows.Forms.LinkLabel();
            this.SuspendLayout();
            // 
            // linkLabel1
            // 
            this.linkLabel1.AutoSize = true;
            this.linkLabel1.LinkArea = new System.Windows.Forms.LinkArea(68, 27);
            this.linkLabel1.Location = new System.Drawing.Point(3, 9);
            this.linkLabel1.Name = "linkLabel1";
            this.linkLabel1.Size = new System.Drawing.Size(203, 42);
            this.linkLabel1.TabIndex = 1;
            this.linkLabel1.TabStop = true;
            this.linkLabel1.Text = "Currently no editing features available.\r\nSend feature requests to\r\nwebcamsnapsho" +
                "t@krapoth.info";
            this.linkLabel1.UseCompatibleTextRendering = true;
            // 
            // SmartWebcamSnapshotContentEditor
            // 
            this.Controls.Add(this.linkLabel1);
            this.Name = "SmartWebcamSnapshotContentEditor";
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		protected override void OnSelectedContentChanged()
		{
			base.OnSelectedContentChanged();
			_settings = new WebcamSnapshotSettings(SelectedContent.Properties);
			//helloWorldControl1.Message = _settings.Message;
		}

		private void helloWorldControl1_MessageChanged(object sender, System.EventArgs e)
		{
			//update the smart content settings
			//_settings.Message = helloWorldControl1.Message;
			//_defaultSettings.Message = _settings.Message; //save the new message as the default

			//notify the editor that the smart content has changed, so it will regenerate the html.
			OnContentEdited();
		}
	}
}
